package com.hashbee.bbs.service.impl;

import com.hashbee.bbs.bo.PageTags;
import com.hashbee.bbs.bo.para.PageQueryPara;
import com.hashbee.bbs.dao.TagsMapper;
import com.hashbee.bbs.domain.Tags;
import com.hashbee.bbs.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("tagService")
public class TagServiceImpl implements TagService {

    @Autowired
    private TagsMapper tagsMapper;

    @Override
    public ArrayList<Tags> queryList(List tags) {
        ArrayList<Tags> tagsArrayList = new ArrayList<>();
        try {
            tagsArrayList = tagsMapper.selectByNames(tags);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        return tagsArrayList;
    }

    @Override
    public PageTags queryPage(PageQueryPara pageQueryPara) {

        PageTags pageTags = new PageTags();
        pageTags.setList(tagsMapper.selectPage(pageQueryPara));
        pageTags.setCount(tagsMapper.selectCount(pageQueryPara));

        return pageTags;
    }


}
